import java.util.Arrays;
import java.util.Scanner;

public class test3 {
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int[] arr = new int[4];
        for (int i = 0; i <4 ; i++) {
            arr[i] = in.nextInt();
        }
        System.out.println(getResult(arr));
    }
    public static int getResult(int[] arr){
        //也就是说需要获取index 02 03 12 13
        return getSum(arr[0],arr[2])+getSum(arr[0],arr[3])+getSum(arr[1],arr[2])+getSum(arr[1],arr[3]);
    }

    public static int getSum(int a,int b){
        if(a%b==0){
            return 1;
        }else{
            return 0;
        }
    }
}
